package cn.xjt.service;

import cn.xjt.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author xu
 * @Description
 * @createTime 2021年03月04日 16:02:00
 */
@Component              //熔断降级
public class DeptClientServerFailBackFactory implements FallbackFactory {
    @Override
    public DeptClientServer create(Throwable throwable) {
        return new DeptClientServer() {
            @Override
            public Dept getDept(Long id) {
                return new Dept().setDeptno(id).setName("由于服务器压力过大，当前服务被关闭，请稍后再试").setDb_source("没有数据~");
            }

            @Override
            public List<Dept> getAll() {
                return null;
            }

            @Override
            public Boolean addDept(Dept dept) {
                return null;
            }
        };
    }
}
